<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="weaver.hrm.resource.ResourceComInfo"%>
<%@page import="weaver.conn.RecordSet"%>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%
ResourceComInfo resourceComInfo = new ResourceComInfo();
int curuserid = user.getUID();
String requestid = Util.null2String(request.getParameter("requestid"));
String hideczlx = Util.null2String(request.getParameter("hideczlx"),"0");
RecordSet rs = new RecordSet();

Map map = new HashMap();

String sql = "select * from workflow_nodebase";
rs.executeSql(sql);
while(rs.next()){
	String id = Util.null2String(rs.getString("id"));
	String nodename = Util.null2String(rs.getString("nodename"));
	String isstart = Util.null2String(rs.getString("isstart"));
	String isend = Util.null2String(rs.getString("isend"));
	map.put("node_"+id, nodename);
	map.put("node_"+id, nodename);
	map.put("node_"+id, nodename);
	map.put("node_isstart_"+id, isstart);
	map.put("node_isend_"+id, isend);
}

sql = "select distinct ll.nodeid,ll.operator,o.requestid,o.userid,o.workflowid,o.isremark,o.nodeid nextnodeid,o.receivedate,o.receivetime,o.operatedate,o.operatetime,n.isstart,h.seclevel,convert(varchar(4000),l.remark) remark,l.destnodeid,l.logtype,l.logid "+
	"from workflow_currentoperator o left join workflow_requestlog l "+
	"on o.requestid=l.requestid and o.nodeid=l.nodeid and o.userid=l.operator "+
	"and ((to_char(dateadd(SECOND,-5,to_date(l.operatedate||' '||l.operatetime)))<=(o.operatedate||' '||o.operatetime) "+
	"and to_char(dateadd(SECOND,5,to_date(l.operatedate||' '||l.operatetime)))>=(o.operatedate||' '||o.operatetime)) or logtype='7') "+
	"left join workflow_requestlog ll "+
	"on o.requestid=ll.requestid and ','||ll.receivedpersonids||',' like '%,'||o.userid||',%' "+
	"and to_char(dateadd(SECOND,-5,to_date(ll.operatedate||' '||ll.operatetime)))<=(o.receivedate||' '||o.receivetime) "+
	"and to_char(dateadd(SECOND,5,to_date(ll.operatedate||' '||ll.operatetime)))>=(o.receivedate||' '||o.receivetime) "+
	"left join hrmresource h on o.userid=h.id "+
	"left join workflow_nodebase n on o.nodeid=n.id "+
	"where o.requestid="+requestid+" order by o.receivedate,o.receivetime,n.isstart desc,h.seclevel desc";
rs.executeSql(sql);
%>
<%!
private String removeHtml(String str){
	String temp = "";
	while(str.indexOf("<")>=0){
		int index = str.indexOf("<");
		temp += str.substring(0,index);
		str = str.substring(index+1);
		index = str.indexOf(">");
		str = str.substring(index+1);
	}
	temp += str;
	return temp;
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
<SCRIPT language="javascript" src="/js/weaver_wev8.js"></script>
<SCRIPT language="javascript" src="/js/weaverTable_wev8.js"></script>
<SCRIPT type="text/javascript" src="/formmode/js/WdatePicker/WdatePicker_wev8.js"></script>
<LINK REL=stylesheet type=text/css HREF=/css/Weaver_wev8.css>
<link href="/formmode/css/formmode_wev8.css" type="text/css" rel="stylesheet" />
<script language=javascript src="/wui/common/jquery/plugin/Listener_wev8.js"></script>
<SCRIPT type="text/javascript" src="/js/workflow/VCEventHandle_wev8.js"></SCRIPT>
<script src='echarts.min.js'></script>
<script src='macarons.js'></script>
<style type="text/css">
*{
	margin: 0;
	padding: 0;
	border: 0;
	list-style-type: none;
	font-size: 14px!important;
	font-family: "Microsoft YaHei"!important;
}
td,th{
	border-bottom: 1px solid white;
	border-right: 1px solid white;
	height: 30px;
	text-align: center;
}
th{
	font-weight: bold;
}
.btn{
	height:30px;
	width: 1100px;
	border: 1px solid black;
	background-color: white;
}
#tablecontainer,#tablecontainer1{ 
	width: 100%; 
	height: 400px; 
	margin: 0 auto; 
}
</style>
<script type="text/javascript">
var isshow = false;
function showorhidden(id){
	if(!isshow){
		$("#jsr"+id).show();
		$("#show"+id).html("隐藏所有接收人");
		isshow = true;
	}else{
		$("#jsr"+id).hide();
		$("#show"+id).html("显示所有接收人");
		isshow = false;
	}
}

function reLb(){
	window.parent.WfForm.doRightBtnEvent("BTN_FORWARD");
}

function update(nodeid, logid, rzid){
	showDialog("/jobs/wuxiszf/alllogs_updatelog.jsp?requestid=<%=requestid%>&nodeid="+nodeid+"&logid="+logid+"&rzid="+rzid);
}

var dialog = null;
function showDialog(url, title){
	var diaHeight = 300;
	var diaWidth = 400;
   	dialog = new top.Dialog();
   	dialog.currentWindow = window;
   	dialog.Drag = true;
   	dialog.Width = diaWidth;
   	dialog.Height = diaHeight;
   	dialog.URL = url;
   	dialog.closeBefore = function(res){
	   	window.location.reLoad();
    }
	dialog.show();
}
</script>
  </head>
  
  <body>
<table style="width:100%;" border="0" cellpadding="0" cellspacing="0">
<tr style="width: 100%;background-color: #4394da;color: white;">
	<th style="width: 4%;border-left: 1px solid white;border-top: 1px solid white;">序号</th>
	<th style="width: 10%;border-top: 1px solid white;">步骤</th>
	<th style="width: 10%;border-top: 1px solid white;">处理人员</th>
	 <!--<%if(hideczlx.equals("1")){ %><th style="width: 10%;border-top: 1px solid white;">处理方式</th><%} %>-->
	<th style="width: 15%;border-top: 1px solid white;">收到时间</th>
	<th style="width: 15%;border-top: 1px solid white;">处理时间</th>
	<th style="width: 30%;border-top: 1px solid white;">办理意见</th>
	<th style="width: 10%;border-top: 1px solid white;">发送人员</th>
</tr>
<%
int index = 0;
while(rs.next()){
	index++;
	String nodeid = Util.null2String(rs.getString("nodeid"));
	String nextnodeid = Util.null2String(rs.getString("nextnodeid"));
	String logtype = Util.null2String(rs.getString("logtype"));
	String operator = Util.null2String(rs.getString("operator"));
	String userid = Util.null2String(rs.getString("userid"));
	String receivedate = Util.null2String(rs.getString("receivedate"));
	String receivetime = Util.null2String(rs.getString("receivetime"));
	String operatedate = Util.null2String(rs.getString("operatedate"));
	String operatetime = Util.null2String(rs.getString("operatetime"));
	String remark = Util.null2String(rs.getString("remark"));
	String isstart = Util.null2String(rs.getString("isstart"));
	
	String czlx = "";
	if(logtype.equals("0")){
		czlx = "批准";
	}else if(logtype.equals("1")){
		czlx = "保存";
	}else if(logtype.equals("2")){
		czlx = "提交";
	}else if(logtype.equals("3")){
		czlx = "退回";
	}else if(logtype.equals("7")){
		czlx = "转发";
	}else if(logtype.equals("9")){
		czlx = "批注";
	}else if(logtype.equals("a")){
		czlx = "意见征询";
	}else if(logtype.equals("b")){
		czlx = "意见征询回复";
	}else if(logtype.equals("e")){
		czlx = "强制归档";
	}else if(logtype.equals("h")){
		czlx = "转办";
	}else if(logtype.equals("i")){
		czlx = "干预";
	}else if(logtype.equals("t")){
		czlx = "抄送";
	}else if(logtype.equals("")){
		operatedate = "";
		operatetime = "";
	}
	remark = removeHtml(remark);
	if(remark.equals("")){
		remark = "<span style='color:gray;'>[未签署]</span>";
	}
	if(isstart.equals("1")&&operator.equals("")){
		operator = userid;
		nodeid = nextnodeid;
	}
%>
<tr style="<%=index%2==0?"background-color: #f5f5f5;":"" %>">
	<td style="border-left: 1px solid white;"><%=index %></td>
	<td nodeid="<%=nextnodeid %>"><%=Util.null2String(map.get("node_"+nextnodeid)) %></td>
	<td userid="<%=userid %>"><%=resourceComInfo.getLastname(userid) %></td>
	 <!--<%if(hideczlx.equals("1")){ %><td><%=czlx %></td><%} %>-->
	<td><%=receivedate+" "+receivetime %></td>
	<td><%=operatedate+" "+operatetime %></td>
	<td style="text-align: left;"><%=remark %></td>
	<td operator="<%=operator %>"><%=resourceComInfo.getLastname(operator) %></td>
</tr>
<%
}
%>
</table>
  </body>
</html>
